package com.system.ad.controller;

import java.util.Arrays;
import java.util.Map;

import com.system.ad.utils.PageUtils;
import com.system.ad.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.system.ad.entity.CreativeUnitEntity;
import com.system.ad.service.CreativeUnitService;




/**
 * 创意和推广单元关联表
 *
 * @author bigfish
 * @email 787838675@qq.com
 * @date 2024-02-01 11:29:39
 */
@RestController
@RequestMapping("ad/creativeunit")
public class CreativeUnitController {
    @Autowired
    private CreativeUnitService creativeUnitService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public Result list(@RequestParam Map<String, Object> params){
        PageUtils page = creativeUnitService.queryPage(params);

        return Result.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public Result info(@PathVariable("id") Long id){
		CreativeUnitEntity creativeUnit = creativeUnitService.getById(id);

        return Result.ok().put("creativeUnit", creativeUnit);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public Result save(@RequestBody CreativeUnitEntity creativeUnit){
		creativeUnitService.save(creativeUnit);

        return Result.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public Result update(@RequestBody CreativeUnitEntity creativeUnit){
		creativeUnitService.updateById(creativeUnit);

        return Result.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public Result delete(@RequestBody Long[] ids){
		creativeUnitService.removeByIds(Arrays.asList(ids));

        return Result.ok();
    }

}
